package org.restoran.service.parser.jackson;

import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
import org.springframework.data.domain.Persistable;

import java.io.IOException;

/**
 * @author Snisar Bogdan.
 */
public class IdentityJsonSerialyzer extends JsonSerializer<Persistable<?>> {

    @Override
    public void serialize(Persistable<?> value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {

        jgen.writeString(value.getId().toString());
    }
}
